package com.woniu.service;

import com.woniu.dao.RbacRoleMenuDao;
import com.woniu.entity.RbacMenu;
import com.woniu.entity.ResponseEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author WenXin
 * @version 1.0
 * @description: TODO
 * @date 2022/9/11 16:15
 */
@Service
public class RbacRoleMenuServiceImlp implements RbacRoleMenuService {
    @Autowired
    RbacRoleMenuDao rbacRoleMenuDao;

    @Override
    public ResponseEntity editRoleMenu(List<RbacMenu> list, int id) {
        //先清空之前的权限，然后增加前端传过来的权限
        int a = rbacRoleMenuDao.deleteById(id);
        int i = rbacRoleMenuDao.editRoleMenu(list, id);
        if (i > 0) {
            return new ResponseEntity(200, "修改菜单权限成功");
        } else {
            return new ResponseEntity(500, "修改菜单权限失败");
        }
    }
}
